#import threading

#	@classmethod
#	def get_instance(cls):	

class Singleton(object):   
	objs  = {}
	def __new__(cls, *args, **kv):
		if cls in cls.objs:
			#print "info, Singleton: Object Already Exists.", str(cls)
			return cls.objs[cls]
		#print "info, Singleton: Create", str(cls)
		cls.objs[cls] = object.__new__(cls)
		if hasattr(cls, 'init_only_once'):
			cls.objs[cls].init_only_once()
		#cls.objs[cls] = super(Singleton, cls).__new__(cls)
		return cls.objs[cls]
    
        
class Test_Singleton(Singleton):
	def f(self):
		self.i = 10
		print self.i
		print "Test_Singleton::f()"
	
        			
if __name__ == '__main__':	
	s1 = Test_Singleton()
	s2 = Test_Singleton()
	
	Test_Singleton().f()
	
	if(id(s1)==id(s2)):
		print "Same"
	else:
		print "Diff"